#pragma once
#include "factory.hpp"
#include <com/otrd/Eeprom/FaultPre/server.hpp>
#include <handler.hpp>
#include <sdbusplus/server/object.hpp>

#include <vector>

namespace com
{
namespace otrd
{

using FaultPreIface = sdbusplus::server::object::object<
    sdbusplus::com::otrd::Eeprom::server::FaultPre>;

/**
 * @class FaultPreHandler
 *
 * 针对故障预测配置的Handler
 */
class FaultPreHandler :
    public Handler,
    public RegisteredInFactory<FaultPreHandler>,
    public FaultPreIface
{
  public:
    FaultPreHandler(const EepromItem& eepromItem,
                    const EepromHandler& eepromHandler);

    /** @brief sets the time synchronize interval.
     *  @param[in] value - time synchronize interval.
     *  @returns time synchronize interval or throws an error.
     */
    uint32_t faultPreFunnel(uint32_t value) override;

    /** @brief sets the time jump threshold.
     *  @param[in] value - time jump threshold.
     *  @returns time jump threshold or throws an error.
     */
    uint32_t faultPreThreshold(uint32_t value) override;

    /**@brief 构建操作mac字段的handler
     */
    static std::unique_ptr<Handler>
        createHandler(const EepromItem& eepromItem,
                      const EepromHandler& eepromHandler)
    {
        return std::make_unique<FaultPreHandler>(eepromItem, eepromHandler);
    }

    /**@brief 获取该handler的名字
     */
    static std::string getHandlerName()
    {
        return "FaultPreHandler";
    }
};

} // namespace otrd
} // namespace com